package DAO;

import entity.Emp;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import utils.Dbutils;

import java.sql.SQLException;
import java.util.List;

/**
 * @author lishunlin110
 * @version 1.0
 * @description: 员工dao实现
 * @date 2021/8/26 21:57
 */
public class EmpDaoImpl implements EmpDao{

    @Override
    public List<Emp> queryAll() {
        QueryRunner queryRunner = new QueryRunner();
        String sql = "select* from emp";
        try {

            List<Emp>empList = queryRunner.query(Dbutils.getConnection(),sql, new BeanListHandler<>(Emp.class));
            return  empList;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
